Install tools tests
authorMatthias Clasen <mclasen@redhat.com>
Wed, 18 Oct 2017 02:41:57 +0000 (10:41 +0800)
committerMatthias Clasen <mclasen@redhat.com>
Wed, 18 Oct 2017 15:30:20 +0000 (17:30 +0200)
At the same time, update the expected test output to match
the current tools output, and write diff and ref files in /tmp.

38 files changed:
testsuite/tools/meson.build
testsuite/tools/settings.in [new file with mode: 0755]
testsuite/tools/simplify-data/test1.expected [new file with mode: 0644]
testsuite/tools/simplify-data/test1.ui [new file with mode: 0644]
testsuite/tools/simplify-data/test2.expected [new file with mode: 0644]
testsuite/tools/simplify-data/test2.ui [new file with mode: 0644]
testsuite/tools/simplify-data/test3.expected [new file with mode: 0644]
testsuite/tools/simplify-data/test3.ui [new file with mode: 0644]
testsuite/tools/simplify-data/test4.expected [new file with mode: 0644]
testsuite/tools/simplify-data/test4.ui [new file with mode: 0644]
testsuite/tools/simplify-data/test5.expected [new file with mode: 0644]
testsuite/tools/simplify-data/test5.ui [new file with mode: 0644]
testsuite/tools/simplify-data/test6.expected [new file with mode: 0644]
testsuite/tools/simplify-data/test6.ui [new file with mode: 0644]
testsuite/tools/simplify-data/test7.expected [new file with mode: 0644]
testsuite/tools/simplify-data/test7.ui [new file with mode: 0644]
testsuite/tools/simplify-data/test8.expected [new file with mode: 0644]
testsuite/tools/simplify-data/test8.ui [new file with mode: 0644]
testsuite/tools/simplify.in [new file with mode: 0755]
testsuite/tools/simplify/test1.expected [deleted file]
testsuite/tools/simplify/test1.ui [deleted file]
testsuite/tools/simplify/test2.expected [deleted file]
testsuite/tools/simplify/test2.ui [deleted file]
testsuite/tools/simplify/test3.expected [deleted file]
testsuite/tools/simplify/test3.ui [deleted file]
testsuite/tools/simplify/test4.expected [deleted file]
testsuite/tools/simplify/test4.ui [deleted file]
testsuite/tools/simplify/test5.expected [deleted file]
testsuite/tools/simplify/test5.ui [deleted file]
testsuite/tools/simplify/test6.expected [deleted file]
testsuite/tools/simplify/test6.ui [deleted file]
testsuite/tools/simplify/test7.expected [deleted file]
testsuite/tools/simplify/test7.ui [deleted file]
testsuite/tools/simplify/test8.expected [deleted file]
testsuite/tools/simplify/test8.ui [deleted file]
testsuite/tools/test-settings.in [deleted file]
testsuite/tools/test-simplify.in [deleted file]
testsuite/tools/tools.test.in [new file with mode: 0644]

index 2515aa548ecbaa40ce9771f3eb1d3eb098e63787..64724d292b764427f56b24617bfcf8be54814ae7 100644 (file)
@@ -1,3 +1,6 @@
+testexecdir = join_paths(installed_test_bindir, 'tools')
+testdatadir = join_paths(installed_test_datadir, 'tools')
+
 bash = find_program('bash', required : false)
 if bash.found()
   test_env = environment()
@@ -5,28 +8,30 @@ if bash.found()
   test_env.set('GTK_QUERY_SETTINGS', get_variable('gtk4_query_settings').full_path())
 
   foreach t : ['simplify', 'settings']
-    configure_file(output : 'test-@0@'.format(t),
-      input : 'test-@0@.in'.format(t),
-      configuration : configuration_data())
-
+    configure_file(output: t,
+                   input: '@0@.in'.format(t),
+                   configuration: configuration_data(),
+                   install: get_option('install-tests'),
+                   install_dir: testexecdir)
     test(t, bash,
-      args : 'test-@0@'.format(t),
-      workdir : meson.current_build_dir(),
-      env : test_env,
-      suite: 'tools')
+         args: 'test-@0@'.format(t),
+         workdir: meson.current_build_dir(),
+         env: test_env,
+         suite: 'tools')
   endforeach
-endif # bash found
+endif
 
-# Installed data
+if get_option('install-tests')
+  foreach t : ['simplify', 'settings']
+    test_conf = configuration_data()
+    test_conf.set('testexecdir', testexecdir)
+    test_conf.set('test', t)
+    configure_file(output: '@0@.test'.format(t),
+                   input: 'tools.test.in',
+                   configuration: test_conf,
+                   install: true,
+                   install_dir: testdatadir)
+  endforeach
 
-test_simplify_data = [
-  'simplify/test1.ui', 'simplify/test1.expected',
-  'simplify/test2.ui', 'simplify/test2.expected',
-  'simplify/test3.ui', 'simplify/test3.expected',
-  'simplify/test4.ui', 'simplify/test4.expected',
-  'simplify/test5.ui', 'simplify/test5.expected',
-  'simplify/test6.ui', 'simplify/test6.expected',
-  'simplify/test7.ui', 'simplify/test7.expected',
-  'simplify/test8.ui', 'simplify/test8.expected',
-]
-# TODO: install in case of installed tests - install_data()
+  install_subdir('simplify-data', install_dir: testexecdir)
+endif
diff --git a/testsuite/tools/settings.in b/testsuite/tools/settings.in
new file mode 100755 (executable)
index 0000000..5e32c80
--- /dev/null
@@ -0,0 +1,17 @@
+#! /bin/bash
+
+GTK_QUERY_SETTINGS=${GTK_QUERY_SETTINGS:-gtk-query-settings}
+TEST_RESULT_DIR=${TEST_RESULT_DIR:-/tmp}
+
+shopt -s nullglob
+
+echo "1..1"
+
+name=gtk-query-settings
+result=$TEST_RESULT_DIR/$name.out
+$GTK_QUERY_SETTINGS 2>/dev/null >$result
+if [ $(wc -l $result | cut -f1 -d' ') -eq 882 ]; then
+  echo "ok 1 $name"
+else
+  echo "not ok 1 $name"
+fi
diff --git a/testsuite/tools/simplify-data/test1.expected b/testsuite/tools/simplify-data/test1.expected
new file mode 100644 (file)
index 0000000..de1472e
--- /dev/null
@@ -0,0 +1,5 @@
+<!-- default property gets stripped -->
+<interface>
+  <object class="GtkWindow">
+  </object>
+</interface>
diff --git a/testsuite/tools/simplify-data/test1.ui b/testsuite/tools/simplify-data/test1.ui
new file mode 100644 (file)
index 0000000..4f03810
--- /dev/null
@@ -0,0 +1,6 @@
+<!-- default property gets stripped -->
+<interface>
+  <object class="GtkWindow">
+    <property name="visible">False</property>
+  </object>
+</interface>
diff --git a/testsuite/tools/simplify-data/test2.expected b/testsuite/tools/simplify-data/test2.expected
new file mode 100644 (file)
index 0000000..99fefb9
--- /dev/null
@@ -0,0 +1,6 @@
+<!-- non-default property not stripped -->
+<interface>
+  <object class="GtkWindow">
+    <property name="visible">1</property>
+  </object>
+</interface>
diff --git a/testsuite/tools/simplify-data/test2.ui b/testsuite/tools/simplify-data/test2.ui
new file mode 100644 (file)
index 0000000..20ffe8d
--- /dev/null
@@ -0,0 +1,6 @@
+<!-- non-default property not stripped -->
+<interface>
+  <object class="GtkWindow">
+    <property name="visible">True</property>
+  </object>
+</interface>
diff --git a/testsuite/tools/simplify-data/test3.expected b/testsuite/tools/simplify-data/test3.expected
new file mode 100644 (file)
index 0000000..6b9c07f
--- /dev/null
@@ -0,0 +1,6 @@
+<!-- translatable property not stripped -->
+<interface>
+  <object class="GtkWindow">
+    <property name="visible" translatable="yes">0</property>
+  </object>
+</interface>
diff --git a/testsuite/tools/simplify-data/test3.ui b/testsuite/tools/simplify-data/test3.ui
new file mode 100644 (file)
index 0000000..2490e79
--- /dev/null
@@ -0,0 +1,6 @@
+<!-- translatable property not stripped -->
+<interface>
+  <object class="GtkWindow">
+    <property name="visible" translatable="yes">False</property>
+  </object>
+</interface>
diff --git a/testsuite/tools/simplify-data/test4.expected b/testsuite/tools/simplify-data/test4.expected
new file mode 100644 (file)
index 0000000..286f106
--- /dev/null
@@ -0,0 +1,6 @@
+<!-- irrelevant comments and context are stripped -->
+<interface>
+  <object class="GtkWindow">
+    <property name="visible">1</property>
+  </object>
+</interface>
diff --git a/testsuite/tools/simplify-data/test4.ui b/testsuite/tools/simplify-data/test4.ui
new file mode 100644 (file)
index 0000000..eb5b0f0
--- /dev/null
@@ -0,0 +1,6 @@
+<!-- irrelevant comments and context are stripped -->
+<interface>
+  <object class="GtkWindow">
+    <property name="visible" comments="foo" context="bla">True</property>
+  </object>
+</interface>
diff --git a/testsuite/tools/simplify-data/test5.expected b/testsuite/tools/simplify-data/test5.expected
new file mode 100644 (file)
index 0000000..1fb898b
--- /dev/null
@@ -0,0 +1,9 @@
+<!-- placeholders are stripped -->
+<interface>
+  <object class="GtkWindow">
+    <child>
+      <object class="GtkBox">
+      </object>
+    </child>
+  </object>
+</interface>
diff --git a/testsuite/tools/simplify-data/test5.ui b/testsuite/tools/simplify-data/test5.ui
new file mode 100644 (file)
index 0000000..e379abd
--- /dev/null
@@ -0,0 +1,12 @@
+<!-- placeholders are stripped -->
+<interface>
+  <object class="GtkWindow">
+    <child>
+      <object class="GtkBox">
+        <child>
+          <placeholder/>
+        </child>
+      </object>
+    </child>
+  </object>
+</interface>
diff --git a/testsuite/tools/simplify-data/test6.expected b/testsuite/tools/simplify-data/test6.expected
new file mode 100644 (file)
index 0000000..8d4495b
--- /dev/null
@@ -0,0 +1,5 @@
+<!-- non-canonical property name works -->
+<interface>
+  <object class="GtkWindow">
+  </object>
+</interface>
diff --git a/testsuite/tools/simplify-data/test6.ui b/testsuite/tools/simplify-data/test6.ui
new file mode 100644 (file)
index 0000000..e4f394d
--- /dev/null
@@ -0,0 +1,6 @@
+<!-- non-canonical property name works -->
+<interface>
+  <object class="GtkWindow">
+    <property name="default_width">-1</property>
+  </object>
+</interface>
diff --git a/testsuite/tools/simplify-data/test7.expected b/testsuite/tools/simplify-data/test7.expected
new file mode 100644 (file)
index 0000000..a75c4d4
--- /dev/null
@@ -0,0 +1,8 @@
+<!-- default child property gets stripped -->
+<interface>
+  <object class="GtkBox">
+    <child>
+      <object class="GtkLabel"/>
+    </child>
+  </object>
+</interface>
diff --git a/testsuite/tools/simplify-data/test7.ui b/testsuite/tools/simplify-data/test7.ui
new file mode 100644 (file)
index 0000000..52e0da2
--- /dev/null
@@ -0,0 +1,12 @@
+<!-- default child property gets stripped -->
+<interface>
+  <object class="GtkBox">
+    <child>
+      <object class="GtkLabel">
+      </object>
+      <packing>
+        <property name="expand">False</property>
+      </packing>
+    </child>
+  </object>
+</interface>
diff --git a/testsuite/tools/simplify-data/test8.expected b/testsuite/tools/simplify-data/test8.expected
new file mode 100644 (file)
index 0000000..df3c407
--- /dev/null
@@ -0,0 +1,11 @@
+<!-- non-default child property remains -->
+<interface>
+  <object class="GtkBox">
+    <child>
+      <object class="GtkLabel"/>
+      <packing>
+        <property name="expand">1</property>
+      </packing>
+    </child>
+  </object>
+</interface>
diff --git a/testsuite/tools/simplify-data/test8.ui b/testsuite/tools/simplify-data/test8.ui
new file mode 100644 (file)
index 0000000..1aec7ad
--- /dev/null
@@ -0,0 +1,12 @@
+<!-- non-default child property remains -->
+<interface>
+  <object class="GtkBox">
+    <child>
+      <object class="GtkLabel">
+      </object>
+      <packing>
+        <property name="expand">True</property>
+      </packing>
+    </child>
+  </object>
+</interface>
diff --git a/testsuite/tools/simplify.in b/testsuite/tools/simplify.in
new file mode 100755 (executable)
index 0000000..642b50f
--- /dev/null
@@ -0,0 +1,31 @@
+#! /bin/bash
+
+GTK_BUILDER_TOOL=${GTK_BUILDER_TOOL:-gtk-builder-tool}
+TEST_DATA_DIR=${TEST_DATA_DIR:-./simplify-data}
+TEST_RESULT_DIR=${TEST_RESULT_DIR:-/tmp}
+
+shopt -s nullglob
+TESTS=( "$TEST_DATA_DIR"/*.ui )
+
+echo "1..${#TESTS}"
+
+I=1
+for t in ${TESTS[*]}; do
+  name=$(basename $t .ui)
+  expected="$TEST_DATA_DIR/$name.expected"
+  result="$TEST_RESULT_DIR/$name.out"
+  diff="$TEST_RESULT_DIR/$name.diff"
+  ref="$TEST_RESULT_DIR/$name.ref"
+
+  $GTK_BUILDER_TOOL simplify $t 2>/dev/null >$result
+
+  if diff -u "$expected" "$result" > "$diff"; then
+    echo "ok $I $name"
+    rm "$diff"
+  else
+    echo "not ok $I $name"
+    cp "$expected" "$ref"
+  fi
+
+  I=$((I+1))
+done
diff --git a/testsuite/tools/simplify/test1.expected b/testsuite/tools/simplify/test1.expected
deleted file mode 100644 (file)
index de1472e..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-<!-- default property gets stripped -->
-<interface>
-  <object class="GtkWindow">
-  </object>
-</interface>
diff --git a/testsuite/tools/simplify/test1.ui b/testsuite/tools/simplify/test1.ui
deleted file mode 100644 (file)
index 4f03810..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-<!-- default property gets stripped -->
-<interface>
-  <object class="GtkWindow">
-    <property name="visible">False</property>
-  </object>
-</interface>
diff --git a/testsuite/tools/simplify/test2.expected b/testsuite/tools/simplify/test2.expected
deleted file mode 100644 (file)
index 20ffe8d..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-<!-- non-default property not stripped -->
-<interface>
-  <object class="GtkWindow">
-    <property name="visible">True</property>
-  </object>
-</interface>
diff --git a/testsuite/tools/simplify/test2.ui b/testsuite/tools/simplify/test2.ui
deleted file mode 100644 (file)
index 20ffe8d..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-<!-- non-default property not stripped -->
-<interface>
-  <object class="GtkWindow">
-    <property name="visible">True</property>
-  </object>
-</interface>
diff --git a/testsuite/tools/simplify/test3.expected b/testsuite/tools/simplify/test3.expected
deleted file mode 100644 (file)
index 2490e79..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-<!-- translatable property not stripped -->
-<interface>
-  <object class="GtkWindow">
-    <property name="visible" translatable="yes">False</property>
-  </object>
-</interface>
diff --git a/testsuite/tools/simplify/test3.ui b/testsuite/tools/simplify/test3.ui
deleted file mode 100644 (file)
index 2490e79..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-<!-- translatable property not stripped -->
-<interface>
-  <object class="GtkWindow">
-    <property name="visible" translatable="yes">False</property>
-  </object>
-</interface>
diff --git a/testsuite/tools/simplify/test4.expected b/testsuite/tools/simplify/test4.expected
deleted file mode 100644 (file)
index 41d8ecc..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-<!-- irrelevant comments and context are stripped -->
-<interface>
-  <object class="GtkWindow">
-    <property name="visible">True</property>
-  </object>
-</interface>
diff --git a/testsuite/tools/simplify/test4.ui b/testsuite/tools/simplify/test4.ui
deleted file mode 100644 (file)
index eb5b0f0..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-<!-- irrelevant comments and context are stripped -->
-<interface>
-  <object class="GtkWindow">
-    <property name="visible" comments="foo" context="bla">True</property>
-  </object>
-</interface>
diff --git a/testsuite/tools/simplify/test5.expected b/testsuite/tools/simplify/test5.expected
deleted file mode 100644 (file)
index 1fb898b..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-<!-- placeholders are stripped -->
-<interface>
-  <object class="GtkWindow">
-    <child>
-      <object class="GtkBox">
-      </object>
-    </child>
-  </object>
-</interface>
diff --git a/testsuite/tools/simplify/test5.ui b/testsuite/tools/simplify/test5.ui
deleted file mode 100644 (file)
index e379abd..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-<!-- placeholders are stripped -->
-<interface>
-  <object class="GtkWindow">
-    <child>
-      <object class="GtkBox">
-        <child>
-          <placeholder/>
-        </child>
-      </object>
-    </child>
-  </object>
-</interface>
diff --git a/testsuite/tools/simplify/test6.expected b/testsuite/tools/simplify/test6.expected
deleted file mode 100644 (file)
index 8d4495b..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-<!-- non-canonical property name works -->
-<interface>
-  <object class="GtkWindow">
-  </object>
-</interface>
diff --git a/testsuite/tools/simplify/test6.ui b/testsuite/tools/simplify/test6.ui
deleted file mode 100644 (file)
index e4f394d..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-<!-- non-canonical property name works -->
-<interface>
-  <object class="GtkWindow">
-    <property name="default_width">-1</property>
-  </object>
-</interface>
diff --git a/testsuite/tools/simplify/test7.expected b/testsuite/tools/simplify/test7.expected
deleted file mode 100644 (file)
index a75c4d4..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-<!-- default child property gets stripped -->
-<interface>
-  <object class="GtkBox">
-    <child>
-      <object class="GtkLabel"/>
-    </child>
-  </object>
-</interface>
diff --git a/testsuite/tools/simplify/test7.ui b/testsuite/tools/simplify/test7.ui
deleted file mode 100644 (file)
index 52e0da2..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-<!-- default child property gets stripped -->
-<interface>
-  <object class="GtkBox">
-    <child>
-      <object class="GtkLabel">
-      </object>
-      <packing>
-        <property name="expand">False</property>
-      </packing>
-    </child>
-  </object>
-</interface>
diff --git a/testsuite/tools/simplify/test8.expected b/testsuite/tools/simplify/test8.expected
deleted file mode 100644 (file)
index d5b6825..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-<!-- non-default child property remains -->
-<interface>
-  <object class="GtkBox">
-    <child>
-      <object class="GtkLabel"/>
-      <packing>
-        <property name="expand">True</property>
-      </packing>
-    </child>
-  </object>
-</interface>
diff --git a/testsuite/tools/simplify/test8.ui b/testsuite/tools/simplify/test8.ui
deleted file mode 100644 (file)
index 1aec7ad..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-<!-- non-default child property remains -->
-<interface>
-  <object class="GtkBox">
-    <child>
-      <object class="GtkLabel">
-      </object>
-      <packing>
-        <property name="expand">True</property>
-      </packing>
-    </child>
-  </object>
-</interface>
diff --git a/testsuite/tools/test-settings.in b/testsuite/tools/test-settings.in
deleted file mode 100755 (executable)
index 5e32c80..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-#! /bin/bash
-
-GTK_QUERY_SETTINGS=${GTK_QUERY_SETTINGS:-gtk-query-settings}
-TEST_RESULT_DIR=${TEST_RESULT_DIR:-/tmp}
-
-shopt -s nullglob
-
-echo "1..1"
-
-name=gtk-query-settings
-result=$TEST_RESULT_DIR/$name.out
-$GTK_QUERY_SETTINGS 2>/dev/null >$result
-if [ $(wc -l $result | cut -f1 -d' ') -eq 882 ]; then
-  echo "ok 1 $name"
-else
-  echo "not ok 1 $name"
-fi
diff --git a/testsuite/tools/test-simplify.in b/testsuite/tools/test-simplify.in
deleted file mode 100755 (executable)
index 6b4f2e8..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-#! /bin/bash
-
-GTK_BUILDER_TOOL=${GTK_BUILDER_TOOL:-gtk-builder-tool}
-TEST_DATA_DIR=${TEST_DATA_DIR:-./simplify}
-TEST_RESULT_DIR=${TEST_RESULT_DIR:-/tmp}
-
-shopt -s nullglob
-TESTS=( "$TEST_DATA_DIR"/*.ui )
-
-echo "1..${#TESTS}"
-
-I=1
-for t in ${TESTS[*]}; do
-  name=$(basename $t .ui)
-  expected="$TEST_DATA_DIR/$name.expected"
-  result="$TEST_RESULT_DIR/$name.out"
-
-  $GTK_BUILDER_TOOL simplify $t 2>/dev/null >$result
-
-  if diff "$expected" "$result" > /dev/null; then
-    echo "ok $I $name"
-  else
-    echo "not ok $I $name"
-  fi
-
-  I=$((I+1))
-done
diff --git a/testsuite/tools/tools.test.in b/testsuite/tools/tools.test.in
new file mode 100644 (file)
index 0000000..24c47ce
--- /dev/null
@@ -0,0 +1,4 @@
+[Test]
+Exec=/bin/sh -c "env G_ENABLE_DIAGNOSTIC=0 TEST_DATA_DIR=@testexecdir@/@test@-data @testexecdir@/@test@"
+Type=session
+Output=TAP